// -----------------------------------------------------------------------
//  <copyright file="GetLoginLogPageQuery.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2025 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2025/1/15 10:30</last-date>
// -----------------------------------------------------------------------

using DaprPlus.Identity.Domain.Entities;


namespace DaprPlus.Identity.Application.Identity.LoginLogs.Queries;

[AuthConfig(typeof(LoginLog), ResourceAccessType.RoleLimit, "GetPage")]
public class GetLoginLogPageQuery : PageQuery<PageResult<LoginLogOutDto>>
{ }

public class GetLoginLogPageQueryHandler(IQueryRepository<LoginLog> queryRepository)
    : IRequestHandler<GetLoginLogPageQuery, PageResult<LoginLogOutDto>>
{
    public async Task<PageResult<LoginLogOutDto>> Handle(GetLoginLogPageQuery request, CancellationToken cancellationToken)
    {
        var spec = new PageQuerySpecification<LoginLog>(request.PageCondition, request.FilterGroup);
        var page = await queryRepository.GetPageAsync<LoginLogOutDto>(spec, cancellationToken);
        return page;
    }
}

